All Questions
Tagged with parsingmath-expression-eval
47 questions
3votes
1answer
71views
Advanced String Calculator with asin, acos, atan Functions in C++
This is a follow-up question for Advanced String Calculator in C++. Considering the suggestions mentioned in MrBean Bremen's answer, I am trying to update the implementation as below. The experimental ...
3votes
1answer
173views
Advanced String Calculator in C++
This is a follow-up question for String Calculator in C++. Considering the suggestions mentioned in MrBean Bremen's answer and Martin York's answer. I am trying to modify the code and trying to ...
4votes
2answers
241views
String Calculator in C++
As a coding exercise, I am trying to implement a calculator which takes string as input, with addition (+), subtraction (-), multiplication (*), division (/) and power (^) functions. For example, ...
2votes
1answer
200views
Evaluate a prefix expression
The algorithm involves using two stacks. One stack (call it token_stack) holds the operators (like +, - etc) and operands (like 3,4 etc) and the other stack (call it count_stack) holds the number of ...
2votes
2answers
121views
Evaluating Polish Prefix Notation and Polish Postfix Notation
In Polish postfix notation, the operators follow their operands. For example, to add 3 and 4 together, the expression is 3 4 + rather than 3 + 4. The conventional notation expression 3 − 4 + 5 becomes ...
3votes
3answers
707views
Command line calculator in C
This code is an arithmetic parser as is the code in a previous question of mine. However this parser handles floating point arguments and mathematical functions, and handles them without needing to ...
8votes
1answer
2kviews
Mathematical expression evaluator (C++)
I'm new to C++ and I decided to experiment with the language, by writing a mathematical expression evaluator, using the Shunting-Yard algorithm. A design choice that may stand out as weird is the fact ...
1vote
1answer
89views
Function to perform a logical NOT in a string
I am using "tinyexpr", a cute library that can solve mathematical formulas in a string and I extended it such that it does logical operations with two operands as well. However I wasn't sure ...
2votes
2answers
288views
A postfix (a.k.a. Reverse-Polish Notation - RPN) calculator
As an exercise, I put together a postfix calculator using modern Fortran. Language apart, I am interested in knowing your take on the algorithm. As far as I remember from my freshman year (chemistry - ...
5votes
2answers
392views
Evaluating arithmetic expressions and plotting graphs
I just got started with Python. I created some code, and I want to know what more experienced devs think about it. What can I do better? What to avoid? ...
3votes
1answer
956views
Infix to postfix notation in Haskell (Shunting-yard algorithm)
I've written an infix to postfix converter in Haskell using the Shunting-yard algorithm. Example of how it works: ...
5votes
1answer
532views
Recursive descent parser for simple arithmetic expressions grammar
What I'd like to see in your review, in order of relevance: Is there any bugs? (I see none, but...) Is the code efficient? (by whatever metric you'd like to use) Is the code easy to understand? ...
6votes
1answer
8kviews
Use Infix expression to construct a binary expression tree
Problem statement Construct a binary expression using infix expression. The infix expression uses extra parenthesis to enforce the priority of operators. For example, infix expression ...
6votes
1answer
443views
String to token vector for expression parsing
My objective is to create a linear algebra calculator that would be able calculate expressions containing vectors, matrices, (eventually complex numbers/imaginary; quaternions), and real numbers. I've ...
6votes
3answers
1kviews
Simple parenthesis removal - JavaScript
I solved the following problem: You will be given a mathematical string and your task will be to remove all braces as follows: ...